<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        div{
            width:1000px ;
            height: 200px;
            margin: 100px auto;
            position: relative;
            overflow: hidden;
        }
        ul{
            position: absolute;
            margin: 0;
            padding: 0;
        }
        ul li{
            float: left;
            list-style: none;
            width: 200px;
            height: 200px;
        }
    </style>
    <script>
        window.onload = function () {
            var oUl = document.getElementsByTagName('ul')[0];//document.getElementsByName()
            var aLi = document.getElementsByTagName('li');
            var speed = 0;
            var oBtn1 = document.getElementById('btn1');
            var oBtn2 = document.getElementById('btn2');
            var oDiv = document.getElementById('div1');
            var timer = null;

            oUl.innerHTML +=oUl.innerHTML;
            oUl.style.width = aLi[0].offsetWidth*aLi.length+'px';

            function moveWall() {
                    if(oUl.offsetLeft<-oUl.offsetWidth/2){//滚完一半的时候再拉回来
                        oUl.style.left='0';
                    }
                    if(oUl.offsetLeft>0){
                        oUl.style.left = -oUl.offsetWidth/2+'px';
                    }

                    oUl.style.left = oUl.offsetLeft+speed+'px';
                 }
                    timer = setInterval(moveWall,30);
                    oDiv.onmouseover = function () {
                       clearInterval(timer);
                   };
                   oDiv.onmouseout = function () {
                       timer= setInterval(moveWall,30);
                   };
                   oBtn1.onclick = function () {
                        speed=-2;
                   };
                   oBtn2.onclick = function () {
                       speed =2;
                   }
        }
    </script>
</head>
<body>
<button id="btn1">向左走</button>
<button id="btn2">向右走</button>

   <div id="div1">
       <ul >
           <li><img src="images2/1.png" alt="" width="200" height="200"></li>
           <li><img src="images2/2.png" alt="" width="200" height="200"></li>
           <li><img src="images2/3.png" alt="" width="200" height="200"></li>
           <li><img src="images2/4.png" alt="" width="200" height="200"></li>
           <li><img src="images2/5.png" alt="" width="200" height="200"></li>
       </ul>
   </div>
</body>
</html>